﻿@model NodePermissionsViewModel
	<form class="form form-horizontal" asp-controller="Administrator" asp-action="NodePermissions" method="post">
		<table class="table table-border table-bordered table-bg table-hover">
			<thead>
				<tr class="text-c">
					<th width="40">ID</th>
					<th>节点名</th>
					@{
						switch (ViewBag.PermissionsType)
						{
							case "Node":
								<th width="100">设置当前节点</th>
								<th width="250">子节点管理<br />（可以添加、修改、删除、排序子节点）</th>
								break;
							case "Content":
							case "Product":
								<th width="100">查看</th>
								<th width="100">录入</th>
								<th width="100">审核</th>
								<th width="100">信息管理</th>
								break;
							case "Comment":
								<th width="100">回复</th>
								<th width="100">审核</th>
								<th width="100">管理</th>
								break;
						}
					}
				</tr>
			</thead>
			<tbody id="tableBody">
				@{
					if (Model != null && Model.NodeList != null)
					{
						@foreach (var node in Model.NodeList)
						{
							<tr class="text-c">
								<td>@node.NodeID</td>
								<td>@node.NodeName</td>
								@switch (ViewBag.PermissionsType)
								{
									case "Node":
										<td>
											@if (Model.RoleNodePermissionsList.Where(item => item.NodeID == node.NodeID && item.OperateCode == ((int)OperateCode.CurrentNodesManage).ToString()).Count() >= 1)
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.CurrentNodesManage).ToString())" name="ModelPurview" checked="checked">
											}
											else
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.CurrentNodesManage).ToString())" name="ModelPurview">
											}
										</td>
										<td>
											@if (Model.RoleNodePermissionsList.Where(item => item.NodeID == node.NodeID && item.OperateCode == ((int)OperateCode.ChildNodesManage).ToString()).Count() >= 1)
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.ChildNodesManage).ToString())" name="ModelPurview" checked="checked">
											}
											else
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.ChildNodesManage).ToString())" name="ModelPurview">
											}
										</td>
										break;
									case "Content":
									case "Product":
										<td>
											@if (Model.RoleNodePermissionsList.Where(item => item.NodeID == node.NodeID && item.OperateCode == ((int)OperateCode.NodeContentPreview).ToString()).Count() >= 1)
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.NodeContentPreview).ToString())" name="ModelPurview" checked="checked">
											}
											else
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.NodeContentPreview).ToString())" name="ModelPurview">
											}
										</td>
										<td>
											@if (Model.RoleNodePermissionsList.Where(item => item.NodeID == node.NodeID && item.OperateCode == ((int)OperateCode.NodeContentInput).ToString()).Count() >= 1)
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.NodeContentInput).ToString())" name="ModelPurview" checked="checked">
											}
											else
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.NodeContentInput).ToString())" name="ModelPurview">
											}
										</td>
										<td>
											@if (Model.RoleNodePermissionsList.Where(item => item.NodeID == node.NodeID && item.OperateCode == ((int)OperateCode.NodeContentCheck).ToString()).Count() >= 1)
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.NodeContentCheck).ToString())" name="ModelPurview" checked="checked">
											}
											else
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.NodeContentCheck).ToString())" name="ModelPurview">
											}
										</td>
										<td>
											@if (Model.RoleNodePermissionsList.Where(item => item.NodeID == node.NodeID && item.OperateCode == ((int)OperateCode.NodeContentManage).ToString()).Count() >= 1)
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.NodeContentManage).ToString())" name="ModelPurview" checked="checked">
											}
											else
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.NodeContentManage).ToString())" name="ModelPurview">
											}
										</td>
										break;
									case "Comment":
										<td>
											@if (Model.RoleNodePermissionsList.Where(item => item.NodeID == node.NodeID && item.OperateCode == ((int)OperateCode.NodeCommentReply).ToString()).Count() >= 1)
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.NodeCommentReply).ToString())" name="ModelPurview" checked="checked">
											}
											else
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.NodeCommentReply).ToString())" name="ModelPurview">
											}
										</td>
										<td>
											@if (Model.RoleNodePermissionsList.Where(item => item.NodeID == node.NodeID && item.OperateCode == ((int)OperateCode.NodeCommentCheck).ToString()).Count() >= 1)
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.NodeCommentCheck).ToString())" name="ModelPurview" checked="checked">
											}
											else
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.NodeCommentCheck).ToString())" name="ModelPurview">
											}
										</td>
										<td>
											@if (Model.RoleNodePermissionsList.Where(item => item.NodeID == node.NodeID && item.OperateCode == ((int)OperateCode.NodeCommentManage).ToString()).Count() >= 1)
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.NodeCommentManage).ToString())" name="ModelPurview" checked="checked">
											}
											else
											{
												<input type="checkbox" value="@node.NodeID:@(((int)OperateCode.NodeCommentManage).ToString())" name="ModelPurview">
											}
										</td>
										break;
								}
							</tr>
						}
					}
				}
			</tbody>
		</table>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
			</div>
		</div>
		<input type="hidden" id="PermissionsType" name="PermissionsType" value="@ViewBag.PermissionsType" />
		<input type="hidden" id="id" name="id" value="@ViewBag.RoleID" />
	</form>